webpackJsonp([11],{

/***/ 0:
/***/ (function(module, exports, __webpack_require__) {


window._ = __webpack_require__(2);

/**
 * We'll load jQuery and the Bootstrap jQuery plugin which provides support
 * for JavaScript based Bootstrap features such as modals and tabs. This
 * code may be modified to fit the specific needs of your application.
 */

/*try {
    window.$ = window.jQuery = require('jquery');

    require('bootstrap-sass');
} catch (e) {}*/

/**
 * We'll load the axios HTTP library which allows us to easily issue requests
 * to our Laravel back-end. This library automatically handles sending the
 * CSRF token as a header based on the value of the "XSRF" token cookie.
 */

window.axios = __webpack_require__(3);

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

/**
 * Next we will register the CSRF Token as a common header with Axios so that
 * all outgoing HTTP requests automatically have it attached. This is just
 * a simple convenience so we don't have to attach every token manually.
 */

var token = document.head.querySelector('meta[name="csrf-token"]');

if (token) {
  window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
  console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}

/**
 * Echo exposes an expressive API for subscribing to channels and listening
 * for events that are broadcast by Laravel. Echo and event broadcasting
 * allows your team to easily build robust real-time web applications.
 */

// import Echo from 'laravel-echo'

// window.Pusher = require('pusher-js');

// window.Echo = new Echo({
//     broadcaster: 'pusher',
//     key: 'your-pusher-key'
// });

/***/ }),

/***/ 1:
/***/ (function(module, exports) {

//设置toastr选项
toastr.options = {
    "closeButton": true,
    "debug": false,
    "progressBar": true,
    "preventDuplicates": false,
    "positionClass": "toast-top-right",
    "onclick": null,
    "showDuration": "400",
    "hideDuration": "1000",
    "timeOut": "1000",
    "extendedTimeOut": "1000",
    "showEasing": "swing",
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
};
window.utils = {
    /**
     *
     * @param data json响应数据
     * @param loadtag 载入标签
     */
    showToastr: function showToastr(data) {
        var loadtag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

        switch (data.status) {
            case 'success':
                toastr.success(data.message, data.title);
                break;
            case 'error':
                toastr.error(data.message, data.title);
                break;
            case 'info':
                toastr.info(data.message, data.title);
                break;
            default:
                toastr.warning(data.message, data.title);
                break;
        }
        if (data.status == 'success') {
            switch (loadtag) {
                case 'reload':
                    utils.reload(data.jumpTime);
                    break;
                case 'goback':
                    utils.goback(data.jumpTime);
                    break;
                case 'go':
                    if (data.url) {
                        utils.redirect(data.url, data.jumpTime);
                    }
                    break;
                default:
                    break;
            }
        }
    },
    bootstraptableOptions: {
        url: '', //请求地址
        method: 'get', //请求方式（*）
        toolbar: '#toolbar', //工具按钮用哪个容器
        striped: true, //是否显示行间隔色
        cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true, //是否显示分页（*）
        sortable: false, //是否启用排序
        sortOrder: "asc", //排序方式
        sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）
        pageNumber: 1, //初始化加载第一页，默认第一页
        pageSize: 10, //每页的记录行数（*）
        pageList: [10, 25, 50, 100], //可供选择的每页的行数（*）
        paginationFirstText: "首页",
        paginationPreText: "上一页", //分页条中上一页按钮的图标或文字
        paginationNextText: "下一页", //分页条中下一页按钮的图标或文字
        paginationLastText: "尾页",
        queryParamsType: "", //limit:获取页面偏移量offset和页面大小pageSize,"":获取当前页数pageNumber和页面大小pageSize
        responseHandler: function responseHandler(response) {
            return {
                rows: response.data,
                total: response.total
            };
        },
        search: false, //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
        contentType: "application/x-www-form-urlencoded",
        strictSearch: true,
        showColumns: true, //是否显示所有的列
        showRefresh: true, //是否显示刷新按钮
        minimumCountColumns: 2, //最少允许的列数
        clickToSelect: true, //是否启用点击选中行
        uniqueId: "no", //每一行的唯一标识，一般为主键列
        showToggle: true, //是否显示详细视图和列表视图的切换按钮
        cardView: false, //是否显示详细视图
        detailView: false, //是否显示父子表
        icons: {
            refresh: 'fa fa-refresh',
            detailOpen: 'fa fa-tasks',
            toggle: 'fa fa-exchange'
        },
        onLoadSuccess: function onLoadSuccess(res) {
            //加载成功时执行
            layer.msg("加载成功", { time: 1000 });
        },
        onLoadError: function onLoadError() {
            //加载失败时执行
            layer.msg("加载数据失败");
        }
    },
    /**
     * 确认框
     * @param url
     * @param data
     * @param title
     * @param content
     */
    confirm: function confirm(url) {
        var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        var callback = arguments[2];
        var title = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '你确定删除么？';
        var content = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '删除后将无法恢复';

        layer.confirm(content, { icon: 3, title: title }, function (index) {
            axios.post(url, data).then(function (response) {
                if (callback) {
                    callback.call(null, response, data);
                } else {
                    utils.showToastr(response.data, 'go');
                }
            }).catch(function (error) {
                if (error.response) {
                    utils.showToastr({
                        'status': 'error',
                        'title': error.response.title,
                        'message': error.response.message
                    });
                } else if (error.request) {
                    console.log(error.request);
                } else {
                    utils.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
                }
            });

            layer.close(index);
        });
    },
    /**
     * 页面跳转，重定向
     * @param url 跳转链接
     * @param times 等待时间
     */
    redirect: function redirect(url) {
        var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;

        if (times > 0) {
            setTimeout(function () {
                window.location.href = url;
            }, times);
        } else {
            window.location.href = url;
        }
    },
    /**
     * 页面刷新
     * @param times 等待时间
     */
    reload: function reload() {
        var times = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;

        if (times) {
            setTimeout(function () {
                window.location.reload();
            }, times);
        } else {
            window.location.reload();
        }
    },
    /**
     * 页面返回
     * @param times 等待时间
     */
    goback: function goback() {
        var times = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;

        if (times) {
            setTimeout(function () {
                window.history.back(-1);
            }, times);
        } else {
            window.history.back(-1);
        }
    },
    /**
     * 异步post请求
     * @param posturl
     * @param data
     * @param callback
     */
    ajaxPost: function ajaxPost(posturl) {
        var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        var callback = arguments[2];

        axios.post(posturl, data).then(function (response) {
            if (callback) {
                callback.call(null, response, data);
            } else {
                utils.showToastr(response.data, 'go');
            }
        }).catch(function (error) {
            if (error.response) {
                utils.showToastr({
                    'status': 'error',
                    'title': error.response.title,
                    'message': error.response.message
                });
            } else if (error.request) {
                console.log(error.request);
            } else {
                utils.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
            }
        });
    },
    /**
     * 异步get请求
     * @param posturl
     * @param data
     * @param callback
     */
    ajaxGet: function ajaxGet(geturl) {
        var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        var callback = arguments[2];

        axios.get(geturl, {
            params: data
        }).then(function (response) {
            if (callback) {
                callback.call(null, response, data);
            } else {
                utils.showToastr(response.data, 'go');
            }
        }).catch(function (error) {
            if (error.response) {
                utils.showToastr({
                    'status': 'error',
                    'title': error.response.title,
                    'message': error.response.message
                });
            } else if (error.request) {
                console.log(error.request);
            } else {
                utils.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
            }
        });
    },
    /**
     * 异步提交表单
     * @param posturl
     * @param data
     */
    ajaxSubmitForm: function ajaxSubmitForm(form, posturl) {
        var otherData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
        var callback = arguments[3];

        var params = $(form).serializeArray();
        var formData = {};
        for (x in params) {
            formData[params[x].name] = params[x].value;
        }
        var postdata = _.merge(formData, otherData);
        posturl = posturl ? posturl : $(form).attr('action');
        if (!posturl) {
            console.log('表单提交路径为空');
        }
        axios.post(posturl, postdata).then(function (response) {
            if (callback) {
                callback.call(null, response, postdata);
            } else {
                utils.showToastr(response.data, 'go');
            }
        }).catch(function (error) {
            if (error.response) {
                utils.showToastr({
                    'status': 'error',
                    'title': error.response.title,
                    'message': error.response.message
                });
            } else if (error.request) {
                console.log(error.request);
            } else {
                utils.showToastr({ 'status': 'error', 'title': '请求错误', 'message': error });
            }
        });
    }
};

/***/ }),

/***/ 53:
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(54);


/***/ }),

/***/ 54:
/***/ (function(module, exports, __webpack_require__) {

/**
 * 载入项目引导文件
 */
__webpack_require__(0);

/**
 * 载入自定义工具
 */

__webpack_require__(1);

//初始化树结构
var initTree = function initTree() {
    var group_id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

    var tree_data = {};
    utils.ajaxGet(page_params.url_list, {}, function (response, data) {
        if (response.data.treeList) {
            tree_data = response.data.treeList;
            $('#tree').treeview({ data: tree_data, levels: 2, showTags: !0, collapseIcon: 'fa fa-chevron-down', expandIcon: 'fa fa-chevron-right' });
            //绑定选中事件
            $('#tree').on('nodeSelected', function (event, data) {
                asxBox = layer.open({
                    type: 1,
                    title: '菜单操作',
                    anim: 2,
                    shadeClose: true, //开启遮罩关闭
                    skin: 'layui-layer-molv', //加上边框
                    area: ['520px', '150px'], //宽高
                    content: $('#box_ask')
                });
                nowNode = data;
            });
        }
    });
};

var box = void 0;
var asxBox = void 0;
var nowNode = void 0;

//不同菜单类别切换输入框
var typechange = function typechange(type) {
    $('.hidebox').hide();
    if ($.inArray(type, ['click', 'scancode_waitmsg', 'scancode_push', 'pic_sysphoto', 'pic_photo_or_album', 'pic_weixin', 'location_select']) != -1) {
        $('.keybox').show();
    }
    if ($.inArray(type, ['media_id', 'view_limited']) != -1) {
        $('.mediaidbox').show();
    }
    if ($.inArray(type, ['view', 'miniprogram']) != -1) {
        $('.urlbox').show();
    }
    if ($.inArray(type, ['miniprogram']) != -1) {
        $('.appidbox,.pagepathbox').show();
    }
};
//个性化设置
var conditionalchange = function conditionalchange(isconditional) {
    if (isconditional == 1) {
        $('.rulebox').show();
    } else {
        $('.rulebox').hide();
    }
};
//构建地区选择元素
var buildAreaHtml = function buildAreaHtml(domId, parentId, defaultVal) {
    var html = '<option value="0">请选择</option>';
    if (page_params.data_area[parentId]) {
        _.each(page_params.data_area[parentId], function (n, k) {
            html += '<option  value="' + n.id + '" ' + (n.id == defaultVal ? 'selected' : '') + '>' + n.name + '</option>';
        });
    }
    $('#' + domId).html(html);
};

$(document).ready(function () {
    //切换树结构
    initTree();
    //菜单类别切换
    typechange($("#type").val());
    $('#type').on('change', function () {
        typechange($(this).val());
    });
    //个性化设置切换
    conditionalchange($("input[name='is_conditional']:checked").val());
    $("input[name='is_conditional']").change(function () {
        conditionalchange($(this).val());
    });
    //初始化地区
    buildAreaHtml('country', 0);
    buildAreaHtml('province', -1);
    buildAreaHtml('city', -1);
    //地区动态切换
    $('#country').change(function () {
        buildAreaHtml('province', $(this).val());
        buildAreaHtml('city', -1);
    });
    $('#province').change(function () {
        buildAreaHtml('city', $(this).val());
    });

    //添加顶级菜单
    $("#btn-add").on('click', function () {
        $("#box-form form").resetForm();
        $("#box-form form").attr('action', page_params.url_add);
        $("#box-form input[name='menu_id']").val(0);
        $("#box-form input[name='parent_id']").val(0);
        typechange($("#type").val());
        conditionalchange($("input[name='is_conditional']:checked").val());
        buildAreaHtml('country', 0);
        buildAreaHtml('province', -1);
        buildAreaHtml('city', -1);
        box = layer.open({
            type: 1,
            title: '添加【顶级菜单】',
            anim: 2,
            shadeClose: true, //开启遮罩关闭
            skin: 'layui-layer-molv', //加上边框
            area: ['620px', '500px'], //宽高
            content: $('#box-form')
        });
    });
    //添加子菜单
    $("#btn-add-child").on('click', function () {
        $("#box-form form").resetForm();
        $("#box-form form").attr('action', page_params.url_add);
        $("#box-form input[name='menu_id']").val(0);
        $("#box-form input[name='parent_id']").val(nowNode.menu_id);
        typechange($("#type").val());
        conditionalchange($("input[name='is_conditional']:checked").val());
        buildAreaHtml('country', 0);
        buildAreaHtml('province', -1);
        buildAreaHtml('city', -1);
        box = layer.open({
            type: 1,
            title: '添加【' + nowNode.display_name + '】子角色',
            anim: 2,
            shadeClose: true, //开启遮罩关闭
            skin: 'layui-layer-molv', //加上边框
            area: ['620px', '500px'], //宽高
            content: $('#box-form')
        });
    });
    //编辑菜单
    $("#btn-edit").on('click', function () {
        $("#box-form form").attr('action', page_params.url_edit);
        $("#box-form form").resetForm();

        $("#box-form input[name='menu_id']").val(nowNode.menu_id);
        $("#box-form input[name='parent_id']").val(nowNode.parent_id);
        $("#box-form input[name='name']").val(nowNode.name);
        $("#box-form select[name='type']").val(nowNode.type);
        typechange(nowNode.type);
        $("#box-form input[name='key']").val(nowNode.key);
        $("#box-form input[name='url']").val(nowNode.url);
        $("#box-form input[name='appid']").val(nowNode.appid);
        $("#box-form input[name='pagepath']").val(nowNode.pagepath);
        $("#box-form input[name='media_id']").val(nowNode.media_id);
        $("#box-form input[name='order_num']").val(nowNode.order_num);
        //个性化设置
        $(":radio[name='is_conditional'][value='" + nowNode.is_conditional + "']").prop("checked", "checked");
        conditionalchange(nowNode.is_conditional);
        //标签
        if (nowNode.matchrule.tag_id) {
            $("#tag_id").val(nowNode.matchrule.tag_id);
        }
        //性别
        if (nowNode.matchrule.sex) {
            $("#sex").val(nowNode.matchrule.sex);
        }
        //客户端版本
        if (nowNode.matchrule.client_platform_type) {
            $("#client_platform_type").val(nowNode.matchrule.client_platform_type);
        }
        //地区
        if (nowNode.matchrule.countryId) {
            buildAreaHtml('country', 0, nowNode.matchrule.countryId);
        } else {
            buildAreaHtml('country', 0);
        }
        if (nowNode.matchrule.countryId && nowNode.matchrule.provinceId) {
            buildAreaHtml('province', nowNode.matchrule.countryId, nowNode.matchrule.provinceId);
        } else if (nowNode.matchrule.countryId) {
            buildAreaHtml('province', nowNode.matchrule.countryId);
        } else {
            buildAreaHtml('province', -1);
        }
        if (nowNode.matchrule.provinceId && nowNode.matchrule.cityId) {
            buildAreaHtml('city', nowNode.matchrule.provinceId, nowNode.matchrule.cityId);
        } else if (nowNode.matchrule.provinceId) {
            buildAreaHtml('city', nowNode.matchrule.provinceId);
        } else {
            buildAreaHtml('city', -1);
        }
        //语言
        if (nowNode.matchrule.language) {
            $("#language").val(nowNode.matchrule.language);
        }
        box = layer.open({
            type: 1,
            title: '编辑菜单',
            anim: 2,
            shadeClose: true, //开启遮罩关闭
            skin: 'layui-layer-molv', //加上边框
            area: ['620px', '500px'], //宽高
            content: $('#box-form')
        });
    });
    //提交表单
    $('#box-form .btn-sub').on('click', function () {
        data = {};
        data.countryId = $("#country").val();
        data.country = $("#country").find("option:selected").text();
        data.provinceId = $("#province").val();
        data.province = $("#province").find("option:selected").text();
        data.cityId = $("#city").val();
        data.city = $("#city").find("option:selected").text();

        utils.ajaxSubmitForm($("#box-form form"), '', data, function (response, postdata) {
            data = response.data;
            utils.showToastr(data);
            if (data.status == 'success') {
                layer.close(box);
                layer.close(asxBox);
                initTree();
            }
        });
    });
    //删除
    $("#btn-del").on('click', function () {
        layer.close(box);
        if (nowNode.nodes && nowNode.nodes.length > 0 || nowNode._nodes && nowNode._nodes.length > 0) {
            layer.alert('该菜单下有子菜单，不可删除', { icon: 2, title: '失败提示', closeBtn: 0, anim: 6 });
            return false;
        }
        var menu_id = 0;
        if (nowNode) {
            menu_id = nowNode.menu_id;
        }
        utils.confirm(page_params.url_del, { 'id': menu_id }, function (response, postdata) {
            data = response.data;
            utils.showToastr(data);
            if (data.status == 'success') {
                layer.close(asxBox);
                initTree();
            }
        }, '确定要删除菜单【' + nowNode.name + '】？');
    });
    //发布推送菜单
    $("#btn-publish").on('click', function () {
        utils.confirm(page_params.url_publish, {}, function (response, postdata) {
            data = response.data;
            utils.showToastr(data);
        }, '你确定发布推送菜单么？', '该推送会更新现有服务号的菜单配置');
    });
    //同步菜单数据
    $("#btn-sync").on('click', function () {
        utils.confirm(page_params.url_sync, {}, function (response, postdata) {
            data = response.data;
            utils.showToastr(data);
            if (data.status == 'success') {
                initTree();
            }
        }, '你确定同步菜单么？', '该同步过程可能花费大量时间');
    });
});

/***/ })

},[53]);